<template>
  <div class="page-style">
    <btn-area @exportExcel="exportExcel" @searchFun="searchFun" />
    <apply-tab :table-data="applyList" />
    <pagination :total="total" @pagination="currentPage" />
  </div>
</template>

<script>
import btnArea from './components/apply-link/btn-area'
import applyTab from './components/apply-link/apply-tab'
import pagination from '@/components/Pagination'
import { getApplyLinkListApi } from '@/api/agent'
export default {
  components: {
    btnArea,
    applyTab,
    pagination
  },
  data() {
    return {
      total: 0,
      brand_id: '',
      anent_id: '',
      status: '', // 0有效 1失效
      p: 1,
      num: 10,
      applyList: []
    }
  },
  created() {
    this.getApplyLinkList()
  },
  methods: {
    currentPage(val) {
      // console.log(val)
      this.p = val.page
      this.num = val.limit
    },
    exportExcel() {
      // console.log('exportExcel')
      import('@/vendor/Export2Excel').then(excel => {
        excel.export_json_to_excel({
          header: [],
          filename: '申请链接列表',
          autoWidth: true,
          data: []
        })
      })
    },
    getApplyLinkList() {
      const data = {
        brand_id: this.brand_id,
        anent_id: this.anent_id,
        status: this.status,
        p: this.p,
        num: this.num
      }
      getApplyLinkListApi(data).then(res => {
        console.log(res)
        this.total = Number(res.count)
        this.applyList = res.list
      })
    },
    searchFun(val) {
      console.log(val)
      this.status = val.status
      this.getApplyLinkList()
    }
  }
}
</script>

<style scoped>

</style>
